package day1205_3;

public class Test2 {
    public static void main(String[] args) {

        Thread  cooker=new Thread(){
            public void run() {
                for(int i=1;i<1000000;i++){
                    System.out.println("正在做饭");
                }
            }
        };
        cooker.start();


        //定义一个匿名类： 继承了Thread类(是Thread的子类)
        Thread  t1=new Thread(){//1.进入新建状态
            public void run() {
                try {
                    cooker.join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                while(true) {
                    System.out.println("我要吃饭");
                    try {
                        Thread.sleep(1500);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        t1.start();//2.进入可运行状态

    }
}
